from PyQt5.QtWidgets import*
from PyQt5.QtCore import*
from PyQt5.QtGui import*
import sys

#帮我直接运行此文件，可以加载到上级目录的ui包
sys.path.append('../')
#print(sys.path)

from ui.Ui_widget_car import Ui_Form  # type: ignore
from drivers.driver_serial import *


class Form(QWidget):
    
    def __init__(self, parent=None):
        super().__init__(parent)
        self.ui = Ui_Form()
        self.ui.setupUi(self)
        
        self.init_ui()

    def init_ui(self):
        serial_ports = scan_serial_ports()
        for device, description in serial_ports:
            print(device, "->", description)
            self.ui.comboBox_2.addItem(description)
            
        
             
if __name__ == '__main__':
    app = QApplication(sys.argv)
    widget = Form()
    widget.show()
    sys.exit(app.exec_())   
